//
//  YKComposeTool.m
//  youkan
//
//  Created by 吴高烽 on 16/4/8.
//  Copyright © 2016年 Honsintech. All rights reserved.
//

#import "YKComposeTool.h"
#import "YKComposeParam.h"
#import "YKHttpTool.h"
#import "MJExtension.h"
@implementation YKComposeTool
+(void)composeWithStatus:(NSString *)status success:(void (^)())success failure:(void (^)(NSError *))failure{
    YKComposeParam *param =[YKComposeParam param];
    param.status =status;
    [YKHttpTool POST:@"https://api.weibo.com/2/statuses/update.json" parameters:param.keyValues success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
    
}
+(void)composeWithStatus:(NSString *)status image:(UIImage *)image success:(void (^)())success failure:(void (^)(NSError *))failure{
//    参数模型
    YKComposeParam *param =[YKComposeParam param];
    param.status =status;
//    上传模型
    YKUplodParam *upParam =[YKUplodParam new];
    upParam.data=UIImagePNGRepresentation(image);
    upParam.name=@"pic";
    upParam.fileName=@"image.png";
    upParam.mimeType=@"image/png";
    [YKHttpTool Upload:@"https://upload.api.weibo.com/2/statuses/upload.json" parameters:param.keyValues uploadParam:upParam success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}
@end
